package com.houdoudou.servlet.app;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;

import javax.mail.SendFailedException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.houdoudou.affair.app.CustomerAffairApp1;
import com.houdoudou.affair.app.SupplierAffairApp1;
import com.houdoudou.bean.AppBack;

public class Customer4App extends HttpServlet {
	private static final long serialVersionUID = 5L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		process(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		process(req, resp);
	}
	

	void process(HttpServletRequest req, HttpServletResponse resp) throws IOException{
		
		String affair="";
		    try {
				req.setCharacterEncoding("UTF-8");
				  resp.setCharacterEncoding("UTF-8");
					 affair=req.getParameter("affair");
					 System.out.println("\n");
					 System.out.println("affair="+affair + "  时间----"+ new Date());
					 System.out.println("");
		    } catch (UnsupportedEncodingException e) {
		    	
		    }		    
		    //搜索附近的自提柜
			 if(affair.equals("searchMachine")){ 
				 CustomerAffairApp1.searchMachine(req, resp);
			 }//根据自提柜查询商家
			 else  if(affair.equals("searchSupplier")){ 
					 CustomerAffairApp1.searchSupplier(req, resp);
				 }//拉取验证码
			 else  if(affair.equals("createTelnumVerify")){ 
				 CustomerAffairApp1.createTelnumVerify(req, resp);
			 }//消费者注册
			 else  if(affair.equals("createCustomer")){ 
				 CustomerAffairApp1.createCustomer(req, resp);
			 }//消费者登陆
			 else  if(affair.equals("login")){ 
				 CustomerAffairApp1.login(req, resp);
			 }//提交订单
			 else  if(affair.equals("createOrder")){ 
				 CustomerAffairApp1.createOrder(req, resp);
			 }//更新支付密码
			 else  if(affair.equals("updatePaySecret")){ 
				 CustomerAffairApp1.updatePaySecret(req, resp);
			 }//用余额支付订单
			 else  if(affair.equals("payOrder")){ 
				 CustomerAffairApp1.payOrder(req, resp);
			 }//用余额支付订单
			 else  if(affair.equals("orderPaid")){ 
				 CustomerAffairApp1.makeOrderPaid(req, resp);
			 }//修改密码
			 else  if(affair.equals("updateSecret")){ 
				 CustomerAffairApp1.updateSecret(req, resp);
			 }//拉取近期订单
			 else  if(affair.equals("pullLatestOrder")){ 
				 CustomerAffairApp1.pullLatestOrder(req, resp);
			 }// 支付保护，
			 else if(affair.equals("protectOrder")){ 
				 CustomerAffairApp1.protectOrder(req, resp);
			 }// 解除支付保护，
			 else if(affair.equals("deProtectOrder")){ 
				 CustomerAffairApp1.deProtectOrder(req, resp);
			 }// 取消订单，
			 else if(affair.equals("cancelOrder")){ 
				 CustomerAffairApp1.cancelOrder(req, resp);
			 }// 创建退款，
			 else  if(affair.equals("createRefund")){ 
				 CustomerAffairApp1.createRefund(req, resp);
			 }// 取消退款，
			 else if(affair.equals("cancelRefund")){ 
				 CustomerAffairApp1.cancelRefund(req, resp);
			 }// 修改退款，
			 else if(affair.equals("updateRefund")){ 
				 CustomerAffairApp1.updateRefund(req, resp);
			 }// 申请退款仲裁，
			 else  if(affair.equals("arbitrateRefund")){ 
				 CustomerAffairApp1.arbitrateRefund(req, resp);
			 } 
			 else{
				 new AppBack(req, resp, false, "事件未定义").send("", "");
			 }
	}
}
